package pw.archipelag.templateGame {
	import flash.display.Sprite;
	import pw.archipelag.loaderGame.interfaceGame.IGame;
	import pw.archipelag.loaderGame.interfaceGame.DescriptionPlayer;
	import flash.utils.setTimeout;
	import pw.archipelag.loaderGame.interfaceGame.skinsPanel.SkinPanelSet;
	import pw.archipelag.loaderGame.interfaceGame.EventLoaderGame;
	import flash.utils.clearTimeout;
	
	public class TemplateGameDefault extends Sprite implements IGame {
		
		private var timeoutEndGame: uint;
		
		public function TemplateGameDefault(): void {}
		
		public function init(descriptionPlayer: DescriptionPlayer) {
			this.readAssets();
			return true;
		}
		
		private function readAssets():void {
			setTimeout(this.finishReadAssets, 3000);
		}
		
		private function finishReadAssets():void {
			this.dispatchEvent(new EventLoaderGame(EventLoaderGame.RESTART_GAME));
		}
		
		//oprogramowanie interfejsu
		
		public function get nameGame(): String {
			return "Gra Archipelag";
		}
		
		public function get classMcHelp(): Class {
			return null;
		}
		
		public function get skinPanelSet(): SkinPanelSet {
			return null
		}
		
		public function start(): void {
			this.timeoutEndGame = setTimeout(this.end, 3000);
		}
		
		public function set isPauseContinue(value: uint): void {
			if (value == 0) clearTimeout(this.timeoutEndGame);
			else if (value == 1) this.timeoutEndGame = setTimeout(this.end, 3000);
		}
		
		private function end(): void {
			var scorePoints: uint = Math.floor(Math.random() * 1000);
			var scorePercent: uint = Math.round(scorePoints / 11);
			this.dispatchEvent(new EventLoaderGame(EventLoaderGame.SAVE_SCORE, {scorePoints: scorePoints, scorePercent: scorePercent}));
		}
		
	}
	
}